Imports IICBusinessLogic.PeriodProcessing

Namespace PeriodProcessing
   ''' <summary>
    ''' reverses a period for a specific student
    ''' </summary>
    ''' <remarks></remarks>
    Public Class StudentReversalRecordsProvider
        Implements IReversalRecordsProvider

        Private student As Student

        Sub New(ByVal student As Student)
            Me.student = student
        End Sub

        Public Sub setReversalRecords(ByVal pr As PeriodProcessReverser, _
                                      ByVal periodProcess As PeriodProcess) Implements IReversalRecordsProvider.setReversalRecords


            pr.ClassMembers = pr.classMemberMapper.findList("PeriodProcessId={0} and studentid={1}", _
                                            periodProcess.PeriodProcessId, student.StudentId)

            pr.DiplomasEarned = pr.diplomaEarnedMapper.findList(" EarnedPeriodProcessId={0} and studentid={1}", _
                                        periodProcess.PeriodProcessId, student.StudentId)

            pr.CertificationsEarned = pr.certificationEarnedMapper.findList(" EarnedPeriodProcessId={0} and studentid={1}", _
                                    periodProcess.PeriodProcessId, student.StudentId)

            Dim diplomaSatReqsWhere = <sql>CertificationEarnedId in (
	                    select CertificationEarnedId
	                    from CertificationEarned c 
	                    where c.EarnedPeriodProcessId={0} and c.StudentId={1})
                      </sql>

            pr.DiplomaSatisfiedRequirements = pr.diplomaSatisfiedMapper.findList(diplomaSatReqsWhere.Value, _
                                periodProcess.PeriodProcessId, student.StudentId)

            Dim certSatReqsWhere = <sql> [ClassMemberId] in 
        (select classmemberid from classmember where PeriodProcessId={0} and studentid={1})
                      </sql>
            pr.CertificationSatisfiedRequirements = pr.certSatReqMapper.findList(certSatReqsWhere.Value, _
                                periodProcess.PeriodProcessId, student.StudentId)

        End Sub

    End Class
End Namespace
